function $(id) {
	return document.getElementById(id);
}
// AJAX INIT
function khoitao_ajax()
{
	var x;
	try 
	{
		x	=	new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
    	try 
		{
			x	=	new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(f) { x	=	null; }
  	}
	if	((!x)&&(typeof XMLHttpRequest!="undefined"))
	{
		x=new XMLHttpRequest();
  	}
	return  x;
}
//	Sieu thi dia oc function
function	Forward(url)
{
	window.location.href = url;
}
function	_postback()
{
	return void(1);
}
function edit_filter(value)
{
	alert(value);	
}	
function noi_bat(cid)
{
	var noi_bat = $("noi_bat-" + cid).innerHTML;
	
	if ( noi_bat == '<img src="images/true.gif">' ) val_noi_bat = "false";
	else val_noi_bat = "true";
	
	var	query	=	"noi_bat="+val_noi_bat+"&cid="+cid;
	var http 	=	khoitao_ajax();
	try
	{
		http.open("POST", "/admin/prog/edit_noi_bat.php");
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Cache-control", "no-cache");		
    	http.onreadystatechange = function()
		{
			if (http.readyState == 4)
			{
				if (http.status == 200)
				{
					$("noi_bat-"+cid).innerHTML = '<img src="images/'+val_noi_bat+'.gif">';
				}
				else
				{
					return false;
				}
			}
		}
		http.send(query);
	}
	catch (e)
	{
		return false;
	}
	return false;
}
function hien_thi(cid)
{
	var hien_thi = $("hien_thi-" + cid).innerHTML;
	
	if ( hien_thi == '<img src="images/true.gif">' ) val_hien_thi = "false";
	else val_hien_thi = "true";
	
	var	query	=	"hien_thi="+val_hien_thi+"&cid="+cid;
	var http 	=	khoitao_ajax();
	try
	{
		http.open("POST", "/admin/prog/edit_hien_thi.php");
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Cache-control", "no-cache");		
    	http.onreadystatechange = function()
		{
			if (http.readyState == 4)
			{
				if (http.status == 200)
				{
					$("hien_thi-"+cid).innerHTML = '<img src="images/'+val_hien_thi+'.gif">';
				}
				else
				{
					return false;
				}
			}
		}
		http.send(query);
	}
	catch (e)
	{
		return false;
	}
	return false;
}
function edit_cat(cid)
{
	var ten = $("cat-" + cid).value;
	
	var	query	=	"ten="+ten+"&cid="+cid;
	var http 	=	khoitao_ajax();
	try
	{
		http.open("POST", "/admin/prog/edit_cat.php");
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Cache-control", "no-cache");		
    	http.onreadystatechange = function()
		{
			if (http.readyState == 4)
			{
				if (http.status == 200)
				{
					$("cat-" + cid).value = ten;
				}
				else
				{
					return false;
				}
			}
		}
		http.send(query);
	}
	catch (e)
	{
		return false;
	}
	return false;
}

// JavaScript Document